Add unit tests for question-bank, feedback-templates, event-validation, event-batching services - #1358
Merged
RUKAYAT-CODER merged 1 commit intoAug 27, 2026
Conversation
…idation, event-batching services Closes rinafcode#1263, rinafcode#1260, rinafcode#1258, rinafcode#1257 — four previously-untested services each get a focused *.spec.ts covering every public method's success and failure/edge-case paths: - QuestionBankService: create (success + repo failure), findByAssessment (pagination shape, defaults, repo failure). - FeedbackTemplatesService: create (defaults + explicit isDefault), findOne (found/NotFoundException), findAll (owner-scoped/unscoped), findDefault, update/remove (partial updates, NotFoundException, ForbiddenException on non-owner), and render (placeholder substitution, verdict thresholds, divide-by-zero guard, rubric/ criterion/level lookups, unknown placeholders). - EventValidationService: missing eventType, unregistered event type, missing required fields, value constraints (min/max/allowedValues), custom validation, validateEventOrThrow, registerSchema/getSchema. - EventBatchingService: addEvent (batch growth, auto-flush at BATCH_SIZE, shutdown discard), forceFlush (persists + clears, no-op on empty, re-queue + rethrow on failure), and the module lifecycle (periodic flush on the configured interval, final flush + interval teardown on destroy). Verified: `npx jest` on all four specs (50 passed), `npm run typecheck` (tsconfig.build.json, which these excluded *.spec.ts files don't affect anyway) and `eslint --fix` are clean.
|
@monique-7arch Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Thank you for contributing to the project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes four issues, each asking for unit test coverage on a previously-untested service:
QuestionBankService:create(success + repository failure) andfindByAssessment(pagination shape, default page/limit, repository failure).FeedbackTemplatesService:create(defaults + explicitisDefault),findOne(found /NotFoundException),findAll(owner-scoped and unscoped),findDefault,update/remove(partial field updates,NotFoundException,ForbiddenExceptionon non-owner), andrender(placeholder substitution, verdict thresholds, the divide-by-zero guard onmaxScore, rubric/criterion/level lookups, unknown placeholders).EventValidationService: missingeventType, an unregistered event type, missing required fields,valueConstraints(min/max/allowedValues), custom validation,validateEventOrThrow, andregisterSchema/getSchema.EventBatchingService:addEvent(batch growth, auto-flush onceBATCH_SIZEis reached, discarding events after shutdown begins),forceFlush(persists and clears the batch, no-op when empty, re-queues and rethrows on a failed insert), and the module lifecycle (periodic flush on the configured interval, final flush + interval teardown ononModuleDestroy).No production code was touched — this is test-only, per each issue's scope.
Test plan
npx jeston all four new spec files — 50 passed, 0 failednpm run typecheck(tsconfig.build.json) — cleaneslinton the new files — clean